package ex1.model;

import java.util.Random;

/***
 * Classe comum a todas as Threads, usadas para calculos
 * @author wakim
 */
public class Container {
	public static int[][] matrix, matrixTrans;
	public static int[] pis;
	public static Coordenadas minValue, maxValue;
	public static Coordenadas minPiValue, maxPiValue;
	
	public static void set( int m, int k ) {
		Random r = new Random();
		int i, j;
		
		matrix = new int[m][k];
		matrixTrans = new int[k][m];
		
		pis = new int[m];
		minValue = new Coordenadas();
		maxValue = new Coordenadas();
		
		maxValue.value = Integer.MIN_VALUE;
		minValue.value = Integer.MAX_VALUE;
		
		for( i = 0; i < m; ++i ) {
			for( j = 0; j < k; ++j ) {
				matrix[i][j] = r.nextInt(201) - 100;
				matrixTrans[j][i] = matrix[i][j];

				if( matrix[i][j] < minValue.value ) {
					minValue.value = matrix[i][j];
					minValue.i = i;
					minValue.j = j;
				}
				
				if( matrix[i][j] > maxValue.value ) {
					maxValue.value = matrix[i][j];
					maxValue.i = i;
					maxValue.j = j;
				}
			}
		}
	}
	
	public static void findMinMaxPi() {
		int i;
		
		maxPiValue = new Coordenadas();
		minPiValue = new Coordenadas();
		
		maxPiValue.value = Integer.MIN_VALUE;
		minPiValue.value = Integer.MAX_VALUE;
		
		for( i = 0; i < pis.length; ++i ) {
			if( pis[i] < minPiValue.value ) {
				minPiValue.i = i;
				minPiValue.value = pis[i];
			}
			if( pis[i] > maxPiValue.value ) {
				maxPiValue.i = i;
				maxPiValue.value = pis[i];
			}
		}
	}
	
	private Container(){}
}
